<?php
// +--------------------------------------------------------------------------
// | ZAIYOUDAO [ 载攸道 先顺得常 ] <http://www.zaiyoudao.com>
// +--------------------------------------------------------------------------
// | Copyright © 2009-2016 载攸道 版权所有 <TEL:17090888854>
// +--------------------------------------------------------------------------
// | Project: YiPHP [ 我会的仅仅是偷懒！ ] <http://www.yiphp.com>
// +--------------------------------------------------------------------------
// | Author: 牛很多戒很多不戒 <n@isdce.com> <http://juexue.wang>
// +--------------------------------------------------------------------------

/**
 * Mall
 */
namespace Mall\Controller;
use Common\Controller\AdminController;
Vendor('Qiniusdk.autoload'); //七牛入口文件引入 
use Qiniu\Auth; 
use Qiniu\Storage\UploadManager;
use Think\Upload;
/**
 * 页面
 */
class UserController extends AdminController{
	
	public function Set_uid(){
		$_SESSION['u_id'] = I("param.u_id");
		if($_SESSION['u_id'] > 1){
			$info = 1;
		}else{
			$info = 2;
		}
		$this->ajaxReturn($info);
	}
	
	/* 初始化 */
	 public function if_session(){
		 $m_common_user = M('common_user');
		  $map['id'] = $_SESSION['u_id'];
		  $map['group_id'] = 9;
		 $map['status'] = 1;
		 $user_info = $m_common_user->where($map)->find();
		 if($user_info['id'] <= 1){
			 $this->error("请选择音乐人",U("Admin/User/Manage"));
		 }else{
			$this->assign("user_info",$user_info);
		 }
		 
	 }
	
	
	/**
	 * 页面管理
	 */
    public function Song(){
		$this->if_session();
		//页面配置
		$page = array(
			'title'=>'单曲管理',
			'keywords'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'description'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'author'=>'YiPHP',
			'robots' => 'all',
		);
		
		//判断是否搜索用户名
		$name = I('param.name');
		if($name){
			$map['name'] = array('like',"%$name%");
		}
		$this->assign('name',$name);
		
		//判断是否搜索状态
		$status = I('param.status');
		if($status){
			$map['status'] = $status;
			$this->assign('status',$status);
		}else{
			$map['status'] = array('in','1,2,3,4');
		}
		
		//开始结束时间
		$begin_time = strtotime(I('param.begin_time'));
		$end_time = strtotime(I('param.end_time'));
		if($begin_time != null and $end_time != null){
			$map['time']  = array(array('egt',$begin_time),array('elt',$end_time),'and');
		}else{
			//默认今天明天
			$begin_time=time();
			$end_time=time()+86400;
		}
		$this->assign('begin_time',$begin_time);
		$this->assign('end_time',$end_time);
		
		
		$m_mall_content = M('mall_content');
		$m_common_user = M('common_user');
		
		$map['type'] = get_mall_model_conf('MALL_SINGLE');
		$map['uid'] = $_SESSION['u_id'];
		
		$_GET['p']=$_GET['p']?$_GET['p']:1;
		$list = $m_mall_content->where($map)->order('sort desc')->page($_GET['p'].',50')->select();
		$count      = $m_mall_content->where($map)->count();// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,50);// 实例化分页类 传入总记录数和每页显示的记录数
		$show       = $Page->show();// 分页显示输出
		$this->assign('pages',$show);
		//查询关联信息
		foreach($list as $i=>$k){
			$umap['id'] = $list[$i]['uid'];
			$udata = $m_common_user->where($umap)->find();
			$list[$i]['nickname'] = $udata['nickname'];
			$list[$i]['img'] = $udata['img'];
		}
		#dump($list);die;
		//赋值
		$this->assign('list',$list);
		
		$status_list = getstatus();
		$this->assign('status_list',$status_list);
		$this->display();
	}
	
	
	/**
	 * 新增页面
	 */
	public function Create(){
		$this->if_session();
		//判断是否是ajax请求 
		/* $accessKey = '8sc_uncdqBnQUYyWViRALobZH33YO_lZKD65Y04a';
		$secretKey = 'FczTgs6OmHBb7jke7pExGeujvxIHXO0trUCIbmBE';
		$auth = new Auth($accessKey, $secretKey);
		$bucketName = 'music';
		$token = $auth->uploadToken($bucketName); */
		
		$m_mall_content = M("mall_content");
		$m_cms_style = M("cms_style");
		if(IS_POST){
		
			//获得数据
			$data = I();
			 $style = $data['style'];
			$data['value'] = I('param.value','','');
			$data['style'] = implode(',',$data['style']);
			$data['uid'] = $_SESSION['u_id'];
			$data['type'] = get_mall_model_conf('MALL_SINGLE');
			$data['time'] = time();
			$data['ip'] = get_client_ip();
			$data['status'] = 2;
			//dump($data);die;
			$result = $m_mall_content->add($data);
			
			if($result){    //设置成功后跳转页面的地址，默认的返回页面是$_SERVER['HTTP_REFERER'] 
				#创建单曲与风格的关联  zyd_cms_style  
				add_style(1,$result,$style); 
				
				$this->success('新增成功', U('Mall/User/Song'));
			} else {    //错误页面的默认跳转页面是返回前一页，通常不需要设置
				$this->error('新增失败');
			}	
		}else{
			#查询语言
			$langue_list = getlangeues();
			#查询流派风格
			$style_list = gettypes();
			/* $this->assign("token",$token); */
			$this->assign("langue_list",$langue_list);
			$this->assign("style_list",$style_list);
			$this->display();
		}
		
	
	}
	
	
	/**
	 * 批量改变页面状态
	 */
	public function Delete($id,$status=0){
		$this->if_session();
		//判断是否是ajax请求
		if(IS_AJAX){
			$m_mall_content = M('mall_content');
			
			$id = $id?$id:I('param.id');
			$status = $status?$status:I('param.status');
			
			if($id){
				$id = explode(',',$id);
				foreach($id as $i=>$k){
					$map['id'] = $id[$i];
					$data['status'] = $status;
					$m_mall_content->where($map)->save($data);
				}
				//返回信息
				$info = get_errcode(0);
			}else{
				$info = get_errcode(10000001);
			}
		}
		
		//返回信息		
		$info = $info?$info:get_errcode(-2);

		$this->ajaxReturn($info);
	}
	
	
	
	/**
	 * 编辑歌曲
	 */
	public function Edit_song(){
		$this->if_session();
		$m_mall_content = M('mall_content');
		
		$map['id'] = I('param.id');
		//判断是否是ajax请求
		if(IS_POST){
			//获得数据
			
			$data = I('');
			unset($data['id']);
			$style = I('param.style');
			$data['style'] = implode(',',I('param.style'));
			$data['value'] = I('param.value','','');
			$data['time'] = time();
			$data['ip'] = get_client_ip();
			$result = $m_mall_content->where($map)->save($data);
			
			if($result){    //设置成功后跳转页面的地址，默认的返回页面是$_SERVER['HTTP_REFERER']  
				#创建单曲与风格的关联  zyd_cms_style  
				add_style(1,$map['id'],$style); 
				$this->success('编辑成功', U('Mall/User/Song'));
			
			} else {    //错误页面的默认跳转页面是返回前一页，通常不需要设置  
			
				$this->error('编辑失败');
			
			}
		
		}else{
			#查询语言
			$langue_list = getlangeues();
			#查询流派风格
			$style_list = gettypes();
			#详情
			$map['type'] = get_mall_model_conf('MALL_SINGLE');
			$map['status'] = array("in",'2,4');
			$map['uid'] = $_SESSION['u_id'];
			$data = $m_mall_content->where($map)->find();
			$style_list = if_style($style_list,$data['style']);
			
			$this->assign('langue_list',$langue_list);
			$this->assign('style_list',$style_list);
			$this->assign('data',$data);
			
			$this->display();
		}
	}
	
	/* 新增活动 */
	public function create_activity(){
		$this->if_session();
		include_once 'upload.func.php';
		$m_mall_content = M("mall_content");
		if(IS_POST){
			$files = getFiles(); 
			foreach($files as $fileInfo) {  
				$res = uploadFile($fileInfo);  
				if(isset($res['dest'])) {  
					$uploadFiles[] = $res['dest'];  
				}  
			} 
			$str = '';
			$uploadFiles=array_filter($uploadFiles);
			/* dump($files);  
			dump($uploadFiles);die; */
			foreach($uploadFiles as $i=>$v){
				$img_name_list = explode("/",$uploadFiles[$i]);
				$count = count($img_name_list);
				$str_str = substr($uploadFiles[$i],1);
				//dump($str_str);die;
				if($i == 0){
					$str .= $str_str;
				}else{
					$str .= ','.$str_str;
				}
				//dump($img_name_list[$count - 1]);
				upload_file_name($img_name_list[$count - 1],$files[$i]['name'],$uploadFiles[$i],$files[$i]['size']);
			}
			
			//获得数据
			$data = I();
			$data['img'] = $str;
			$style = I('param.style');
			$data['style'] = implode(',',I('param.style'));
			$data['value'] = I('param.value','','');
			$data['uid'] = $_SESSION['u_id'];
			$data['type'] = get_mall_model_conf('MALL_ACTIVITY');
			$data['time'] = time();
			$data['release_time'] = strtotime(I("param.release_time"));
			$data['ip'] = get_client_ip();
			$data['status'] = 2;
			$result = $m_mall_content->add($data);
			
			if($result){    //设置成功后跳转页面的地址，默认的返回页面是$_SERVER['HTTP_REFERER']
				#创建单曲与风格的关联  zyd_cms_style  
				add_style(3,$result,$style); 
				
				$this->success('新增成功', U('Mall/User/activity'));
			} else {    //错误页面的默认跳转页面是返回前一页，通常不需要设置
				$this->error('新增失败');
			}	
		}else{
			
			#查询流派风格
			$style_list = gettypes();
			
			/* $this->assign("token",$token); */
			$this->assign("style_list",$style_list);
			$this->display();
		}
	}
	
	/**
	 *活动列表 
	 */
    public function Activity(){
		$this->if_session();
		$m_mall_content = M('mall_content');
		$m_common_user = M('common_user');
		
		//页面配置
		$page = array(
			'title'=>'活动列表',
			'keywords'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'description'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'author'=>'YiPHP',
			'robots' => 'all',
		);
		
		//判断是否搜索用户名
		$name = I('param.name');
		if($name){
			$map['name'] = array('like',"%$name%");
		}
		$this->assign('name',$name);
		
		//判断是否搜索状态
		$status = I('param.status');
		if($status){
			$map['status'] = $status;
			$this->assign('status',$status);
		}else{
			$map['status'] = array('in','1,2,3,4');
		}
		
		
		//开始结束时间
		$begin_time = strtotime(I('param.begin_time'));
		$end_time = strtotime(I('param.end_time'));
		if($begin_time != null and $end_time != null){
			$map['time']  = array(array('egt',$begin_time),array('elt',$end_time),'and');
		}else{
			//默认今天明天
			$begin_time=time();
			$end_time=time()+86400;
		}
		$this->assign('begin_time',$begin_time);
		$this->assign('end_time',$end_time);
		
		
		$map['type'] = get_mall_model_conf('MALL_ACTIVITY');
		$map['uid'] = $_SESSION['u_id'];
		$_GET['p']=$_GET['p']?$_GET['p']:1;
		
		$list = $m_mall_content ->where($map)->order('sort desc')->page($_GET['p'].',50')->select();
		$count      = $m_mall_content ->where($map)->count();// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,50);// 实例化分页类 传入总记录数和每页显示的记录数
		$show       = $Page->show();// 分页显示输出
		$this->assign('pages',$show);
		//查询关联信息
		foreach($list as $i=>$k){
			$style_name = array();
			$umap['id'] = $list[$i]['uid'];
			$udata = $m_common_user->where($umap)->find();
			
			$list[$i]['nickname'] = $udata['nickname'];
			$list[$i]['img'] = $udata['img'];
			
			$list[$i]['style_name'] = style_str($list[$i]['style']);
		
		}
		
		//dump($list);die;
		//赋值
		$this->assign('list',$list);
		$status_list = getstatus();
		$this->assign('status_list',$status_list);
		$this->display();
	}
	
	/**
	 * 歌单列表（音乐人）
	 */
    public function playlist(){
		$this->if_session();
		$m_mall_content = M('mall_content');
		
		//获得菜单信息
		$map['type'] = get_mall_model_conf('MALL_PLAYLIST');
		$map['uid'] = $_SESSION['u_id'];
		$map['status'] = 1;
		$list = $m_mall_content->where($map)->order('sort desc')->select();
		
		//赋值
		$this->assign('list',$list);
		$this->display();
	}
	
		/**
	 * 编辑菜单
	 */
	public function Edit_playlist(){
    
		$this->if_session();
		//判断是否是ajax请求
		if(IS_AJAX){

			$m_mall_content = M('mall_content');
			$map['id'] = I('param.id');
			$map['uid'] = $_SESSION['u_id'];
			$data = I('');
			unset($data['id']);
		
			$result = $m_mall_content->where($map)->save($data);
			
			//返回信息
			$info = $result?get_errcode(0):get_errcode(-1);
		
		}
		
		//返回信息		
		$info = $info?$info:get_errcode(-2);

		$this->ajaxReturn($info);
	}
	
	/**
	 * 批量删除菜单
	 */
	public function Delete_playlist($id,$status=0){
		$this->if_session();
	
		//判断是否是ajax请求
		if(IS_AJAX){
				
			$m_mall_content = M('mall_content');
		
			$id = $id?$id:I('param.id');
			$status = $status?$status:I('param.status');
			
			if($id){
				$id = explode(',',$id);
				foreach($id as $i=>$k){
					$map['id'] = $id[$i];
					$data['status'] = $status;
					$m_mall_content->where($map)->save($data);
					
				}
				
				//返回信息
				$info = get_errcode(0);
			
			}else{
				
				$info = get_errcode(10000001);
			}
		}
		
		//返回信息		
		$info = $info?$info:get_errcode(-2);
		$this->ajaxReturn($info);
	}
	
	/**
	 * 页面管理
	 */
    public function set_playlist(){
		$this->if_session();
		//页面配置
		$page = array(
			'title'=>'单曲管理',
			'keywords'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'description'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'author'=>'YiPHP',
			'robots' => 'all',
		);
		
		//判断是否搜索用户名
		$name = I('param.name');
		if($name){
			$map['name'] = array('like',"%$name%");
		}
		$this->assign('name',$name);
		
		//开始结束时间
		$begin_time = strtotime(I('param.begin_time'));
		$end_time = strtotime(I('param.end_time'));
		if($begin_time != null and $end_time != null){
			$map['time']  = array(array('egt',$begin_time),array('elt',$end_time),'and');
		}else{
			//默认今天明天
			$begin_time=time();
			$end_time=time()+86400;
		}
		$this->assign('begin_time',$begin_time);
		$this->assign('end_time',$end_time);
		
		
		$m_mall_content = M('mall_content');
		$m_common_user = M('common_user');
		
		$map['type'] = get_mall_model_conf('MALL_SINGLE');
		$map['uid'] = $_SESSION['u_id'];
		$map['status'] = 1;
		
		$_GET['p']=$_GET['p']?$_GET['p']:1;
		$list = $m_mall_content->where($map)->order('sort desc')->page($_GET['p'].',50')->select();
		$count      = $m_mall_content->where($map)->count();// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,50);// 实例化分页类 传入总记录数和每页显示的记录数
		$show       = $Page->show();// 分页显示输出
		$this->assign('pages',$show);
		//查询关联信息
		foreach($list as $i=>$k){
			$umap['id'] = $list[$i]['uid'];
			$udata = $m_common_user->where($umap)->find();
			$list[$i]['nickname'] = $udata['nickname'];
			$list[$i]['img'] = $udata['img'];
		}
		//赋值
		$this->assign('list',$list);
		
		$status_list = getstatus();
		$this->assign('status_list',$status_list);
		
		#歌单列表
		$playlist_map['type'] = get_mall_model_conf('MALL_PLAYLIST');
		$playlist_map['uid'] = $_SESSION['u_id'];
		$playlist_map['status'] = 1;
		$playlist_list = $m_mall_content->where($playlist_map)->select();
		$this->assign('playlist_list',$playlist_list);
		$this->display();
	}
	
	
	/* 新增专辑 */
	 public function create_album(){
		 $this->if_session();
		 
		 include_once 'upload.func.php';
		$m_mall_content = M("mall_content");
		 
		 if(IS_POST){
			$files = getFiles();  
			
			foreach($files as $fileInfo) {  
				$res = uploadFile($fileInfo);  
				if(isset($res['dest'])) {  
					$uploadFiles[] = $res['dest'];  
				}  
			} 
			$str = '';
			$uploadFiles=array_filter($uploadFiles);
			/* dump($files);  
			dump($uploadFiles);die; */
			foreach($uploadFiles as $i=>$v){
				$img_name_list = explode("/",$uploadFiles[$i]);
				$count = count($img_name_list);
				$str_str = substr($uploadFiles[$i],1);
				//dump($str_str);die;
				if($i == 0){
					$str .= $str_str;
				}else{
					$str .= ','.$str_str;
				}
				//dump($img_name_list[$count - 1]);
				upload_file_name($img_name_list[$count - 1],$files[$i]['name'],$uploadFiles[$i],$files[$i]['size']);
			}
			$data['mp3'] = $str;
			 dump($data);die;
			$data['langue'] = I("param.langue");         //语言
			$data['type'] = implode(',',I("param.type"));             //流派风格
			$data['name'] = I("param.name");             //专辑名称
			$data['lyrics'] = I("param.lyrics");          //作词
			$data['compose'] = I("param.compose");        //作曲
			$data['arranged'] = I("param.arranged");      //编曲
			$data['record'] = I("param.record");           //录音
			$data['mixing'] = I("param.mixing");           //混音
			$data['singer'] = I("param.singer");           //演唱者
			$data['producer'] = I("param.producer");       //制作人
			$data['producers'] = I("param.producers");       //出品方
			$data['money'] = I("param.money");       //出售单价
			$data['inventory'] = I("param.inventory");       //发行量
			$data['release_time'] = strtotime(I("param.release_time"));       //发行时间
			$data['img'] = I("param.img");       //封面图
			$data['bottom_img'] = I("param.bottom_img");       //封底图
			$data['color_img'] = I("param.color_img");       //宣传彩页图
			$data['foil_img'] = I("param.foil_img");       //歌词本底衬页图
			$data['intro'] = I("param.intro");       //专辑介绍
			$data['time'] = time();
			$data['type'] = get_mall_model_conf('MALL_ALBUM');
			$data['ip'] = get_client_ip();
			$data['status'] = 2;
			$data['uid'] = $_SESSION['u_id'];
			
			$result = $m_mall_content->add($data);
			if($result){    //设置成功后跳转页面的地址，默认的返回页面是$_SERVER['HTTP_REFERER'] 
				$this->success('新增成功', U('Mall/User/Album'));
			} else {    //错误页面的默认跳转页面是返回前一页，通常不需要设置  
				$this->error('新增失败');
			}
		 }else{
			 #查询语言
			$langeue_list = getlangeues();
			#查询流派风格
			$type_list = gettypes();
			
			$this->assign("langeue_list",$langeue_list);
			$this->assign("type_list",$type_list);
			$this->assign("time",time());
			$this->display();			
		 }
	 }
	
	/**
	 *  专辑管理
	 */
    public function  Album(){
		$this->if_session();
		$m_mall_content = M('mall_content');
		$m_common_user = M('common_user');
		
		
		//判断是否搜索用户名
		$name = I('param.name');
		if($name){
			$map['name'] = array('like',"%$name%");
		}
		$this->assign('name',$name);
		
		//判断是否搜索状态
		$status = I('param.status');
		if($status){
			$map['status'] = $status;
			$this->assign('status',$status);
		}else{
			$map['status'] = array('in','1,2,3,4');
		}
		//开始结束时间
		$begin_time = strtotime(I('param.begin_time'));
		$end_time = strtotime(I('param.end_time'));
		if($begin_time != null and $end_time != null){
			$map['time']  = array(array('egt',$begin_time),array('elt',$end_time),'and');
		}else{
			//默认今天明天
			$begin_time=time();
			$end_time=time()+86400;
		}
		$this->assign('begin_time',$begin_time);
		$this->assign('end_time',$end_time);
		
		$map['type'] = get_mall_model_conf('MALL_ALBUM');
		$map['uid'] = $_SESSION['u_id'];
		$list = $m_mall_content->where($map)->order('time desc')->page($_GET['p'].',50')->select();
		#dump($map);die;
		$count      = $m_mall_content->where($map)->count();// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,50);// 实例化分页类 传入总记录数和每页显示的记录数
		$show       = $Page->show();// 分页显示输出 
		$this->assign('pages',$show);
		
		$status_list = getstatus();
		//dump($status_list);die;
		//赋值
		$this->assign('list',$list);
		$this->assign('status_list',$status_list);
		$this->display();
	}
	
	
	
	/* 编辑专辑 */
	 public function Edit_album(){
		 $this->if_session();
		$m_mall_content = M('mall_content');
		
		$map['id'] = I('param.id');
		//判断是否是ajax请求
		if(IS_POST){
			
			$data['langue'] = I("param.langue");         //语言
			$data['style'] = I("param.style");             //流派风格
			$data['name'] = I("param.name");             //专辑名称
			$data['lyrics'] = I("param.lyrics");          //作词
			$data['compose'] = I("param.compose");        //作曲
			$data['arranged'] = I("param.arranged");      //编曲
			$data['record'] = I("param.record");           //录音
			$data['mixing'] = I("param.mixing");           //混音
			$data['singer'] = I("param.singer");           //演唱者
			$data['producer'] = I("param.producer");       //制作人
			$data['producers'] = I("param.producers");       //出品方
			$data['money'] = I("param.money");       //出售单价
			$data['inventory'] = I("param.inventory");       //发行量
			$data['release_time'] = strtotime(I("param.release_time"));       //发行时间
			$data['img'] = I("param.img");       //封面图
			$data['bottom_img'] = I("param.bottom_img");       //封底图
			$data['color_img'] = I("param.color_img");       //宣传彩页图
			$data['foil_img'] = I("param.foil_img");       //歌词本底衬页图
			$data['intro'] = I("param.intro");       //专辑介绍
			
			$data['ip'] = get_client_ip();
			
			$result = $m_mall_content->where($map)->save($data);
			
			if($result){    //设置成功后跳转页面的地址，默认的返回页面是$_SERVER['HTTP_REFERER']
				$this->success('编辑成功', U('Mall/User/Album'));
			} else {    //错误页面的默认跳转页面是返回前一页，通常不需要设置
				$this->error('编辑失败');
			}
		
		}else{
			$map['type'] = get_mall_model_conf('MALL_ALBUM');
			$map['status'] = array('in','2,4');
			$map['uid'] = $_SESSION['u_id'];
			$data = $m_mall_content->where($map)->find();
			 #查询语言
			$langeue_list = getlangeues();
			#查询流派风格
			$type_list = gettypes();
			$this->assign("langeue_list",$langeue_list);
			$this->assign("type_list",$type_list);
			$this->assign('data',$data);
			$this->display();
		}
		 
	 }
	
	
	/**
	 * 页面管理
	 */
    public function playlist_details(){
		$this->if_session();
		//页面配置
		$page = array(
			'title'=>'歌单详情',
			'keywords'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'description'=>'YiPHP [ 我会的仅仅是偷懒！]',
			'author'=>'YiPHP',
			'robots' => 'all',
		);
		
		//判断是否搜索用户名
		$name = I('param.name');
		if($name){
			$map['name'] = array('like',"%$name%");
		}
		$this->assign('name',$name);
		
		//开始结束时间
		$begin_time = strtotime(I('param.begin_time'));
		$end_time = strtotime(I('param.end_time'));
		if($begin_time != null and $end_time != null){
			$map['time']  = array(array('egt',$begin_time),array('elt',$end_time),'and');
		}else{
			//默认今天明天
			$begin_time=time();
			$end_time=time()+86400;
		}
		$this->assign('begin_time',$begin_time);
		$this->assign('end_time',$end_time);
		
		
		$m_mall_content = M('mall_content');
		$m_common_user = M('common_user');
		
		$details_map['id'] = I("param.id");
		$details_map['status'] = 1;
		$details_map['type'] = 20;
		$details_data = $m_mall_content->where($details_map)->find();
		
		$map['type'] = get_mall_model_conf('MALL_SINGLE');
		$map['status'] = 1;
		$map['uid'] = $_SESSION['u_id'];
		$map['id'] = array("in",$details_data['value']);
		
		$_GET['p']=$_GET['p']?$_GET['p']:1;
		$list = $m_mall_content->where($map)->order('sort desc')->page($_GET['p'].',50')->select();
		$count      = $m_mall_content->where($map)->count();// 查询满足要求的总记录数
		$Page       = new \Think\Page($count,50);// 实例化分页类 传入总记录数和每页显示的记录数
		$show       = $Page->show();// 分页显示输出
		$this->assign('pages',$show);
		//查询关联信息
		foreach($list as $i=>$k){
			$umap['id'] = $list[$i]['uid'];
			$udata = $m_common_user->where($umap)->find();
			$list[$i]['nickname'] = $udata['nickname'];
			$list[$i]['img'] = $udata['img'];
		}
		//赋值
		$this->assign('list',$list);
		
		$status_list = getstatus();
		$this->assign('status_list',$status_list);
		
		#歌单id
		$this->assign("details_data",$details_data);
		
		$this->display();
	}
	
	/**
	 * 新增菜单
	 */
	public function Create_playlist(){
		$this->if_session();
		//判断是否是ajax请求
		if(IS_AJAX){

			$m_mall_content = M('mall_content');
			//获得数据
			$data = I();
			
			$data['uid'] = $_SESSION['u_id'];
			$data['type'] = get_mall_model_conf('MALL_PLAYLIST');
			$data['time'] = time();
			$data['ip'] = get_client_ip();
			$data['status'] = 1;
			
			$result = $m_mall_content->add($data);
			//返回信息
			$info = $result?get_errcode(0):get_errcode(-1);
		}
		
		//返回信息		
		$info = $info?$info:get_errcode(-2);

		$this->ajaxReturn($info);
	}
	
	
}